package com.dc.android_study

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.dc.diffutil.AsyncListDifferActivity
import com.dc.viewpager.ViewPagerActivity

class MainActivity : AppCompatActivity() {

    private val array = arrayOf(
        ActivityEntity("AsyncListDiffer", AsyncListDifferActivity::class.java),
        ActivityEntity("ViewPager2", ViewPagerActivity::class.java)
    )

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val recyclerView: RecyclerView = findViewById(R.id.rv)
        val mainAdapter = MainAdapter(this, array.toMutableList())
        mainAdapter.mItemClick = {_, entity ->
            startActivity(Intent(this, entity.clazz))
        }
        recyclerView.apply {
            adapter = mainAdapter
            layoutManager = LinearLayoutManager(this@MainActivity)

        }
    }
}